package com.river.springbootdemo.thinkingjava.contructor;

/**
 * 验证构造器内部的多态行为，在未初始化完全的情况下多态调用子类重写方法
 */
class Glyph {
    void draw() {
        System.out.println("Glyph.draw");
    }

    Glyph() {
        System.out.println("Glyph() before draw()");
        draw();
        System.out.println("Glyph() after draw()");
    }
}

class RoundGlyph extends Glyph {
    private int radius = 1;

    RoundGlyph(int r) {
        radius = r;
        System.out.println("RoundGlyph.RoundGlyph().radius = " + radius);
    }

    @Override
    void draw() {
        System.out.println("RoundGlyph.draw(),radius = " + radius);
    }
}

public class PolyConstructors {
    public static void main(String[] args) {
        new RoundGlyph(2);
    }
}
